<?php

namespace app\admin\validate;

use think\Validate;

class ProductMerge extends Validate
{
    // 验证规则
    protected $rule = [
        'id'                => 'require|integer',
        'productname'       => 'require|max:255',
        'producturlname'    => 'require|max:255',
        'primary_pid'       => 'require|integer',
        'sales_pids'        => 'max:2000',
        'recommend_pids'    => 'max:2000',
        'product_photo'     => 'max:2000',
        'closeshots_photo'  => 'max:2000',
        'pmv_id'           => 'integer',
        'smv_id'           => 'max:1000',
        'describe'         => 'require',
        'seotitle'         => 'require|max:200',
        'seodesc'          => 'require|max:1000',
        'views_number'     => 'integer',
        'creator'          => 'integer',
        'create_time'      => 'date',
        'updater'          => 'integer',
        'update_time'      => 'date',
        'is_del'           => 'integer|in:0,1',
        'status'           => 'in:0,1',
    ];

    // 错误信息
    protected $message = [
        'id.require'              => 'ID不能为空',
        'id.integer'             => 'ID必须为整数',
        'productname.require'     => '聚合商品名称不能为空',
        'productname.max'        => '聚合商品名称不能超过255个字符',
        'producturlname.require' => 'URL商品名称不能为空',
        'producturlname.max'     => 'URL商品名称不能超过255个字符',
        'primary_pid.require'    => '主SKU商品不能为空',
        'primary_pid.integer'    => '主SKU商品必须为整数',
        'sales_pids.max'        => '组合售卖SKU商品不能超过2000个字符',
        'recommend_pids.max'    => '推荐SKU商品不能超过2000个字符',
        'product_photo.max'     => '商品照片不能超过2000个字符',
        'closeshots_photo.max'  => 'close shots图片不能超过2000个字符',
        'pmv_id.integer'        => '主视频ID必须为整数',
        'smv_id.max'            => '副视频不能超过1000个字符',
        'describe.require'      => '商品描述不能为空',
        'seotitle.max'          => 'SEO标题不能超过200个字符',
        'seotitle.require'      => 'SEO标题不能为空',
        'seodesc.max'           => 'SEO描述不能超过1000个字符',
        'seodesc.require'       => 'SEO描述不能为空',
        'views_number.integer'  => '浏览数必须为整数',
        'creator.integer'       => '创建人ID必须为整数',
        'create_time.date'      => '创建时间格式不正确',
        'updater.integer'       => '更新人ID必须为整数',
        'update_time.date'      => '更新时间格式不正确',
        'is_del.integer'        => '删除标记必须为整数',
        'is_del.in'             => '删除标记值无效',
        'status.in'             => '状态值无效'
    ];

    // 验证场景
    protected $scene = [
        'create' => [
            'productname',
            'producturlname',
            'primary_pid',
            'sales_pids',
            'recommend_pids',
            'product_photo',
            'closeshots_photo',
            'pmv_id',
            'smv_id',
            'describe',
            'full_describe',
            'qanda_describe',
            'seotitle',
            'seodesc',
            'status'
        ],
        'update' => [
            'id',
            'productname',
            'producturlname',
            'primary_pid',
            'sales_pids',
            'recommend_pids',
            'product_photo',
            'closeshots_photo',
            'pmv_id',
            'smv_id',
            'describe',
            'full_describe',
            'qanda_describe',
            'seotitle',
            'seodesc',
            'status'
        ],
        'delete' => ['id', 'is_del'],
        'read' => ['id']
    ];
}
